﻿using System.Windows.Input;

using DanielVaughan;
using DanielVaughan.Services;
using DanielVaughan.Windows;

namespace CalciumTemplateApp.Views.Examples
{
	public class PreventsNavigationViewModel : UserViewModel
	{
		static int pageCount;

		public PreventsNavigationViewModel() : base("page " + ++pageCount)
		{
			NavigatedTo += HandleNavigatedTo;
			NavigatingFrom += HandleNavigatingFrom;
		}

		void HandleNavigatingFrom(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if (preventNavigation)
			{
				e.Cancel = true;
			}
		}
		
		void HandleNavigatedTo(object sender, System.EventArgs e)
		{
		}

		bool preventNavigation;

		public bool PreventNavigation
		{
			get
			{
				return preventNavigation;
			}
			set
			{
				Assign("PreventNavigation", ref preventNavigation, value);
			}
		}
	}
}
